package com.sgb.kjwl.view.ui.activity.pick;

import android.Manifest;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.view.ViewTreeObserver;

import androidx.core.content.ContextCompat;
import androidx.core.widget.NestedScrollView;
import androidx.databinding.DataBindingUtil;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;

import com.apeng.permissions.EsayPermissions;
import com.apeng.permissions.OnPermission;
import com.chuanglan.shanyan_sdk.OneKeyLoginManager;
import com.chuanglan.shanyan_sdk.listener.OneKeyLoginListener;
import com.chuanglan.shanyan_sdk.listener.OpenLoginAuthListener;
import com.sgb.alimaplibrary.util.ToastUtil;
import com.sgb.kjwl.AppActivity;
import com.sgb.kjwl.R;
import com.sgb.kjwl.api.GsonManager;
import com.sgb.kjwl.databinding.ActivityPickNoticeBidDetailBinding;
import com.sgb.kjwl.di.pick.DaggerPickComponent;
import com.sgb.kjwl.di.pick.PickModule;
import com.sgb.kjwl.model.entity.LoginEntity;
import com.sgb.kjwl.model.entity.UserMsgEntity;
import com.sgb.kjwl.model.entity.pick.PickNoticeDetailEntity;
import com.sgb.kjwl.model.entity.pick.TenderDictEntity3;
import com.sgb.kjwl.model.entity.user.OneKeyLoginEntity;
import com.sgb.kjwl.utils.ConfigUtils;
import com.swgk.core.event.EventConstant;
import com.sgb.kjwl.view.event.LoginEvent;
import com.sgb.kjwl.view.ui.activity.MainActivity;
import com.sgb.kjwl.view.ui.activity.WebViewX5HostActivity;
import com.sgb.kjwl.view.ui.activity.manage.WebsiteInfoActivity;
import com.sgb.kjwl.view.ui.activity.self.userInfo.VerificationCodeLoginActivity;
import com.sgb.kjwl.view.ui.adapter.pick.PickNoticeDetailAdapter;
import com.sgb.kjwl.view.widget.pick.PickEmploymentShareDialog;
import com.swgk.core.mmkvutil.CacheMarker;
import com.sgb.kjwl.viewmodel.pick.PickNoticeBidDetailModel;
import com.swgk.core.base.di.AppComponent;
import com.swgk.core.dialog.DialogHelper;
import com.swgk.core.mmkvutil.MkvUtils;
import com.swgk.core.util.ClickUtils;
import com.swgk.core.util.DateUtils;
import com.swgk.core.util.MToast;
import com.swgk.core.util.SharedPreferenceUtil;

import org.greenrobot.eventbus.EventBus;

import java.sql.Timestamp;
import java.util.List;
import java.util.Objects;

import javax.inject.Inject;

/**
 * 中标公告，公告详情
 */
public class PickNoticeBidDetailActivity extends AppActivity {

    private ActivityPickNoticeBidDetailBinding binding;
    private int type;
    private int comType;

    @Inject
    PickNoticeBidDetailModel detailModel;
    private String noticeId;
    private PickNoticeDetailEntity.NoticeInfoBean noticeInfoBean;
    private int page = 1;
    private PickNoticeDetailAdapter adapter;

    public static void start(Context context, String id) {
        Intent intent = new Intent(context, PickNoticeBidDetailActivity.class);
        intent.putExtra("noticeId", id);
        context.startActivity(intent);
    }

    @Override
    protected void setupActivityComponent(AppComponent appComponent) {
        DaggerPickComponent.builder()
                .appComponent(appComponent)
                .pickModule(new PickModule(this))
                .build()
                .inject(this);
    }

    @Override
    protected void initView() {
        binding = DataBindingUtil.setContentView(this, R.layout.activity_pick_notice_bid_detail);
        binding.ivBack.setOnClickListener(view -> finish());
        binding.setClickListener(this);
        binding.setViewModel(detailModel);
        binding.expandView.setOnClickListener(this);
        binding.describeExpandView.setOnClickListener(this);
        binding.imgZbqygz.setOnClickListener(this);
        binding.tvFocus.setOnClickListener(this);
        binding.tvReport.setOnClickListener(this);
        binding.imageReport.setOnClickListener(this);
        binding.tvUserFocus.setOnClickListener(this);
        binding.imageUserFocus.setOnClickListener(this);
        binding.tvCompanyType.setOnClickListener(this);
        binding.pickCompany.setOnClickListener(this);
        binding.companyName.setOnClickListener(this);
        binding.imgBackTop.setOnClickListener(this);
        binding.shareImageView.setOnClickListener(this);


        if (adapter == null) {
            adapter = new PickNoticeDetailAdapter(this, null);
        }
        DividerItemDecoration divider = new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL);
        divider.setDrawable(ContextCompat.getDrawable(getActivity(), R.drawable.shape_list_divide1));
        binding.recyclerWinningBids.addItemDecoration(divider);
        binding.recyclerWinningBids.setLayoutManager(new LinearLayoutManager(this));
        binding.recyclerWinningBids.setAdapter(adapter);
        binding.neSc.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
            @Override
            public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
                if (scrollY == (v.getChildAt(0).getMeasuredHeight() - v.getMeasuredHeight())) {
                    page = page + 1;
                    detailModel.findWinNoticeDetailGoodsPage(noticeId, page);
                }
            }
        });
    }

    @Override
    protected void init() {
        noticeId = getIntent().getStringExtra("noticeId");
        detailModel.getDetail(noticeId);
        detailModel.findWinNoticeDetailGoodsPage(noticeId, page);
    }

    public void showWinningBids(List<List<TenderDictEntity3>> lists, int total) {
        if (page > 1) {
            if (lists.size() > 0) {
                adapter.addDatas(lists);
            }
            binding.llWinningBids.setVisibility(View.VISIBLE);
        } else {
            if (lists.size() > 0) {
                binding.llWinningBids.setVisibility(View.VISIBLE);
                adapter.setDatas(lists);
            } else {
                binding.llWinningBids.setVisibility(View.GONE);
                adapter.setDatas(null);
            }
        }
    }

    @SuppressLint("SetTextI18n")
    public void showData(PickNoticeDetailEntity data) {
        if (data == null) {
            return;
        }
        noticeInfoBean = detailModel.detailEntity.get().getNoticeInfo();
        if (data.getNoticeInfo().getWinType() == 1) {  //1, "企业投标"；2, "个人投标"
            binding.companyName.setTextColor(getResources().getColor(R.color.color_0286DF));
            binding.tvCompanyType.setText("企业");
            binding.tvCompanyType.setBackgroundResource(R.drawable.bg_price);
        } else if (data.getNoticeInfo().getWinType() == 2) {
            binding.companyName.setTextColor(getResources().getColor(R.color.color_tab_one));
            binding.tvCompanyType.setText("个人");
            binding.tvCompanyType.setBackgroundResource(R.drawable.bg_orange);
        }
        if("1".equals(data.getNoticeInfo().getNoticeType())){  // 1-招标 2-竞价
            binding.nameType.setText("招标");
        }else if("2".equals(data.getNoticeInfo().getNoticeType())){
            binding.nameType.setText("竞价");
        }
        if (data.getNoticeInfo().getState() == 9) {
            binding.llFb.setVisibility(View.VISIBLE);
            binding.tvFbReason.setVisibility(View.VISIBLE);
            binding.tvFbReason.setText("废标原因：" + data.getNoticeInfo().getCancelReason());
            binding.tvFbTime.setVisibility(View.VISIBLE);
            binding.tvFbTime.setText("废标时间：" + data.getNoticeInfo().getCancelTime());
            binding.tvBStatus.setVisibility(View.VISIBLE);
        } else {
            binding.llFb.setVisibility(View.GONE);
        }
        /* else {
            binding.tvBStatus.setText("已中标");
            binding.tvBStatus.setTextColor(getResources().getColor(R.color.new_blue));
            binding.tvBStatus.setBackground(getResources().getDrawable(R.drawable.corner_eef4ff_left999_bg));
        }
        binding.tvBStatus.setVisibility(View.VISIBLE);*/
        if (data.getNoticeInfo().getWinCompanyName().equals("") || data.getNoticeInfo().getWinCompanyName() == null) {
            binding.companyName.setClickable(false);
            binding.imgZbqygz.setVisibility(View.GONE);
            binding.llCompany.setVisibility(View.GONE);
        }
        if (data.getNoticeInfo().getNoticeType().equals("2")) {
            binding.surveyLayout.setVisibility(View.GONE);
            binding.supervisorLayout.setVisibility(View.GONE);
            binding.supervisortelLayout.setVisibility(View.GONE);
        }

        if (TextUtils.isEmpty(data.getNoticeInfo().getRemark())) {
            binding.surveyLayout.setVisibility(View.GONE);
        }
        if (TextUtils.isEmpty(data.getNoticeInfo().getSupervisor())) {
            binding.supervisorLayout.setVisibility(View.GONE);
        }
        if (TextUtils.isEmpty(data.getNoticeInfo().getSupervisorTel())) {
            binding.supervisortelLayout.setVisibility(View.GONE);
        }

        if (Objects.requireNonNull(detailModel.detailEntity.get()).getNoticeInfo().getName().length() <= 15) {
            binding.titleView.setText(Objects.requireNonNull(detailModel.detailEntity.get()).getNoticeInfo().getName());
        } else {
            binding.titleView.setText(Objects.requireNonNull(detailModel.detailEntity.get()).getNoticeInfo().getName().substring(0, 12) + "...");
        }
        binding.surveyView.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
            @Override
            public boolean onPreDraw() {
                binding.surveyView.getViewTreeObserver().removeOnPreDrawListener(this);
                int line = binding.surveyView.getLineCount();
                if (line <= 3) {
                    binding.expandView.setVisibility(View.GONE);
                }
                return false;
            }
        });
        binding.describeView.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
            @Override
            public boolean onPreDraw() {
                binding.describeView.getViewTreeObserver().removeOnPreDrawListener(this);
                int line = binding.describeView.getLineCount();
                if (line <= 3) {
                    binding.describeExpandView.setVisibility(View.GONE);
                }
                return false;
            }
        });

        if (noticeInfoBean.getShowEndTimeFlag() == 0) {
            binding.tvEndTime.setVisibility(View.GONE);
        } else {
            binding.tvEndTime.setVisibility(View.VISIBLE);
            showCudownTime(noticeInfoBean.getShowEndTime() + "", "公示结束倒计时: ");
        }

        //企业是否关注
        if (noticeInfoBean.isConcernEnterprises()) {
            binding.tvFocus.setText("已关注");
            binding.tvFocus.setTextColor(getResources().getColor(R.color.color_999999));
            binding.tvFocus.setBackgroundResource(R.drawable.corner5_999999_bg);
        } else {
            binding.tvFocus.setText("关注");
            binding.tvFocus.setTextColor(getResources().getColor(R.color.color_main));
            binding.tvFocus.setBackgroundResource(R.drawable.corner5_ff2928_bg_pick);
        }

        //中标企业是否关注
        if (noticeInfoBean.isWinningConcernEnterprises()) {
            binding.imgZbqygz.setImageDrawable(getResources().getDrawable(R.mipmap.icn_gz));
        } else {
            binding.imgZbqygz.setImageDrawable(getResources().getDrawable(R.mipmap.icn_qxgz));
        }

        //标是否关注
        if (noticeInfoBean.getUserFocusFlag() == 0) {
            binding.imageUserFocus.setImageDrawable(getResources().getDrawable(R.mipmap.guanzhu_pick));
            binding.tvUserFocus.setText("关注");
            binding.tvUserFocus.setTextColor(getResources().getColor(R.color.color_tab_two));
        } else {
            binding.imageUserFocus.setImageDrawable(getResources().getDrawable(R.mipmap.yiguanzhu));
            binding.tvUserFocus.setText("已关注");
            binding.tvUserFocus.setTextColor(getResources().getColor(R.color.color_main));
        }


        //中标总价
        if (TextUtils.isEmpty(data.getNoticeInfo().getWinPrice())) {
            binding.llWinPrice.setVisibility(View.GONE);
        } else {
            binding.llWinPrice.setVisibility(View.VISIBLE);
        }
        //综合得分
        if (TextUtils.isEmpty(data.getNoticeInfo().getScore())) {
            binding.llScore.setVisibility(View.GONE);
        } else {
            binding.llScore.setVisibility(View.VISIBLE);
        }

        binding.nameNotice.setOnClickListener(this);
    }

    public void setIsGz(boolean isGz) {
        if (isGz) {
            binding.tvFocus.setText("关注");
            binding.tvFocus.setTextColor(getResources().getColor(R.color.color_main));
            binding.tvFocus.setBackgroundResource(R.drawable.corner5_ff2928_bg_pick);
            noticeInfoBean.setConcernEnterprises(false);
            MToast.showLongToast1(this, "已取消关注企业", Gravity.CENTER);
        } else {
            binding.tvFocus.setText("已关注");
            binding.tvFocus.setTextColor(getResources().getColor(R.color.color_999999));
            binding.tvFocus.setBackgroundResource(R.drawable.corner5_999999_bg);
            noticeInfoBean.setConcernEnterprises(true);
            MToast.showLongToast1(this, "关注企业成功", Gravity.CENTER);
        }
    }

    public void setZbqyIsGz(boolean isGz) {
        if (isGz) {
            binding.imgZbqygz.setImageDrawable(getResources().getDrawable(R.mipmap.icn_qxgz));
            noticeInfoBean.setWinningConcernEnterprises(false);
            MToast.showToast(this, "已取消关注招标");
        } else {
            binding.imgZbqygz.setImageDrawable(getResources().getDrawable(R.mipmap.icn_gz));
            noticeInfoBean.setWinningConcernEnterprises(true);
            MToast.showToast(this, "关注招标成功");
        }
    }

    public void setTvIsGz(int isGz) {
        //标是否关注
        if (isGz == 1) {
            binding.imageUserFocus.setImageDrawable(getResources().getDrawable(R.mipmap.guanzhu_pick));
            binding.tvUserFocus.setText("关注");
            binding.tvUserFocus.setTextColor(getResources().getColor(R.color.color_tab_two));
            detailModel.detailEntity.get().getNoticeInfo().setUserFocusFlag(0);
            MToast.showLongToast1(this, "已取消关注招标", Gravity.CENTER);
        } else {
            binding.imageUserFocus.setImageDrawable(getResources().getDrawable(R.mipmap.yiguanzhu));
            binding.tvUserFocus.setText("已关注");
            binding.tvUserFocus.setTextColor(getResources().getColor(R.color.color_main));
            detailModel.detailEntity.get().getNoticeInfo().setUserFocusFlag(1);
            MToast.showLongToast1(this, "关注招标成功", Gravity.CENTER);
        }
    }

    private void showCudownTime(String midTime, String text) {
        if (!TextUtils.isEmpty(midTime)) {
            String st = DateUtils.stampToDate(midTime);//结束或者开始时间
            String nt = DateUtils.stampToDate(System.currentTimeMillis() + "");//当前时间
            Timestamp t = Timestamp.valueOf(st);
            Timestamp n = Timestamp.valueOf(nt);
            if (n.before(t)) {
                //没过期
                long nl = System.currentTimeMillis();
                long sl = (long) Long.valueOf(midTime);
                time2((sl - nl) / 1000, text);
            }
        }
    }

    private long midTime;
    private String info;

    public void time2(long midTime, String info) {
        this.midTime = midTime;
        this.info = info;
        runnable.run();
    }

    private Runnable runnable = new Runnable() {
        private String time;

        @Override
        public void run() {
            if (midTime > 0) {
                midTime--;
               /* long dd = midTime / 24 / 60 / 60 % 60;
                long hh = (midTime - dd * 24 * 60 * 60) / 60 / 60 % 60;
                long mm = (midTime - dd * 24 * 60 * 60 - hh * 60 * 60) / 60 % 60;
                long ss = midTime % 60;*/
                long dd = midTime / 86400;
                long hh = midTime % 86400 / 3600;            //转换小时
                long mm = midTime % 86400 % 3600 / 60;            //转换分钟
                long ss = midTime % 86400 % 3600 % 60;            //剩余秒数

                if (dd > 0) {
                    time = info + dd + "天" + hh + "小时" + mm + "分钟" + ss + "秒";
                } else {
                    if (hh > 0) {
                        time = info + hh + "小时" + mm + "分钟" + ss + "秒";
                    } else {
                        if (mm > 0) {
                            time = info + mm + "分钟" + ss + "秒";
                        } else {
                            time = info + ss + "秒";
                        }
                    }
                }

                Message message = Message.obtain();
                message.what = 2;
                message.obj = time;
                timeHandler.sendMessage(message);
//                Log.e("倒计时", time);
                timeHandler.postDelayed(runnable, 1000);
            } else {
                timeHandler.removeCallbacks(runnable);
            }
        }
    };

    @SuppressLint("HandlerLeak")
    private Handler timeHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            if (msg.what == 2) {
                binding.tvEndTime.setText((String) msg.obj);
            }
        }
    };

    @Override
    public void onClick(View v) {
        super.onClick(v);

        switch (v.getId()) {
            case R.id.company_name:
            case R.id.pick_company:
                goToWebsiteInfo(Objects.requireNonNull(detailModel.detailEntity.get()).getNoticeInfo().getComNo());
                break;
            case R.id.expand_view:
                if (binding.expandView.getText().equals("展开")) {
                    binding.surveyView.setMaxLines(Integer.MAX_VALUE);
                    binding.expandView.setText("收起");
                } else {
                    binding.surveyView.setMaxLines(3);
                    binding.expandView.setText("展开");
                }
                break;
            case R.id.describe_expand_view:
                if (binding.describeExpandView.getText().equals("展开")) {
                    binding.describeView.setMaxLines(Integer.MAX_VALUE);
                    binding.describeExpandView.setText("收起");
                } else {
                    binding.describeView.setMaxLines(3);
                    binding.describeExpandView.setText("展开");
                }
                break;
            case R.id.tv_focus:
                type = 0;
                comType = 0;
                if ("".equals(SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.LOGIN_TOKEN, ""))) {
                    jumpLogin();
                } else {
                    checkAddTokenView();
                }
                break;
            case R.id.img_zbqygz:
                type = 0;
                comType = 1;
                if ("".equals(SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.LOGIN_TOKEN, ""))) {
                    jumpLogin();
                } else {
                    detailModel.checkToken("");
                }
                Log.e("中标企业关注", "");
                break;
            case R.id.tv_user_focus:
            case R.id.image_user_focus:
                type = 1;
                if ("".equals(SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.LOGIN_TOKEN, ""))) {
                    jumpLogin();
                } else {
                    checkAddTokenView();
                }
                break;
            case R.id.tv_report:
            case R.id.image_report:
                ReportActivity.start(this, noticeId, "1");
                break;
            case R.id.name_notice:
                if (noticeInfoBean.getNoticeType().equals("1")) {   //中标公告类型1-招标 2-竞价
                    TenderDetailsActivity3.start(getActivity(), noticeInfoBean.getTenderNo(), 0);
                } else if (noticeInfoBean.getNoticeType().equals("2")) {
                    detailModel.getUrlSetting(noticeInfoBean.getTenderNo());
                }
                break;
            case R.id.tv_company_type:
                if (binding.tvCompanyType.getText().equals("企业")) {
                    goToWebsiteInfo(noticeInfoBean.getComNo());
                }
                break;
            case R.id.img_back_top:
                binding.neSc.fullScroll(View.FOCUS_UP);
                binding.neSc.setNestedScrollingEnabled(false);
                break;
            case R.id.share_image_view:
                if (!ClickUtils.isDoubleClick()) {
                    PickEmploymentShareDialog dialog = new PickEmploymentShareDialog(noticeInfoBean.getName(),noticeInfoBean.getWeixinFenXiangUrl(),
                            noticeInfoBean.getWeixinFenXiangMsg(),noticeInfoBean.getComName(),noticeInfoBean.getWinPrice(),noticeInfoBean.getWinTimeStr(),4,this,null);
                    dialog.setDialogClickCallBack(new PickEmploymentShareDialog.DialogClickCallBack() {
                        @Override
                        public void onItemClick(String name) {
                            runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    ToastUtil.show(PickNoticeBidDetailActivity.this,name);
                                }
                            });
                        }
                    }).show();
                }
                break;
        }
    }

    public void getUrl(String url, String id) {
        WebViewX5HostActivity.start(PickNoticeBidDetailActivity.this, url, id);
    }

    private void goToWebsiteInfo(String ComNo) {
        if (TextUtils.isEmpty(ComNo)) {
            ToastUtil.show(getActivity(), "企业店铺no不能为空");
            return;
        }
        WebsiteInfoActivity.start(getActivity(), ComNo, WebsiteInfoActivity.WEBSITE_FOR_COMPANY);
    }

    /**
     * 一键登录成功
     *
     * @param loginEntity
     * @param phoneNumber
     */
    public void loginSucceed(LoginEntity loginEntity, String phoneNumber) {
        LoginEvent loginEvent = new LoginEvent();
        loginEvent.setMessageData(phoneNumber);
        loginEvent.setMessageTag(EventConstant.EVENT_NOTICE_BID_DETAIL_JUMP);
        loginEvent.setObject(loginEntity);
        EventBus.getDefault().postSticky(loginEvent);
    }

    public void getUserMsgSucceed(UserMsgEntity userMsgEntity) {
        LoginEvent loginEvent = new LoginEvent();
        loginEvent.setMessageTag(EventConstant.EVENT_USER_MSG);
        loginEvent.setMessageData(userMsgEntity);
        EventBus.getDefault().postSticky(loginEvent);
    }

    public void checkTokenView() {
        Intent intent = new Intent();
        intent.putExtra("showPage", "FRAGMENT_SHOPPING");
        MainActivity.start(PickNoticeBidDetailActivity.this, intent);

    }

    public void toLogin() {
        SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.LOGIN_TOKEN, "");
        SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.LOGIN_PHONE, "");
        MToast.showToast(this, "登录失效，请重新登录");
        //LoginActivity.start(this);
        jumpLogin();
    }

    public void checkAddTokenView() {
        if (type == 0) {//关注企业
            if (comType == 0) {
                detailModel.userFocus(noticeInfoBean.getComNo(), noticeInfoBean.isConcernEnterprises(), comType);
            } else {
                detailModel.userFocus(noticeInfoBean.getWinCompany(), noticeInfoBean.isWinningConcernEnterprises(), comType);
            }
        } else {
            detailModel.editTender(noticeInfoBean.getNo(), noticeInfoBean.getUserFocusFlag());
        }
    }

    public void jumpLogin() {
        boolean shanyan = MkvUtils.get().getBoolean(MkvUtils.CommomData, CacheMarker.ShanYan, false);
        if (shanyan) {
            //校验权限
            //申请动态权限
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                //6.0以上运行时权限处理
                EsayPermissions.with(PickNoticeBidDetailActivity.this).constantRequest().permission(PERMISSIONS).request(new OnPermission() {
                    @Override
                    public void hasPermission(List<String> granted, boolean isAll) {
                        openLoginPage();
                    }

                    @Override
                    public void noPermission(List<String> denied, boolean quick) {
                        openLoginPage();
                    }
                });

            } else {
                //有权限
                openLoginPage();
            }

        } else {
            VerificationCodeLoginActivity.start(PickNoticeBidDetailActivity.this, EventConstant.EVENT_NOTICE_BID_DETAIL_JUMP);
        }
    }

    //闪验
    static final String[] PERMISSIONS = new String[]{
            Manifest.permission.READ_PHONE_STATE
    };

    /**
     * 拉起授权页
     */
    private void openLoginPage() {
        //设置授权页样式
        OneKeyLoginManager.getInstance().setAuthThemeConfig(ConfigUtils.getCJSConfig(this));
        //开始拉取授权页
        DialogHelper.showProgressDialog(this, null, "数据加载中", 0, true, null).setCanceledOnTouchOutside(true);
        OneKeyLoginManager.getInstance().openLoginAuth(false, new OpenLoginAuthListener() {
            @Override
            public void getOpenLoginAuthStatus(int code, String result) {
                DialogHelper.dismissProgressDialog();
                if (code != 1000) {
                    VerificationCodeLoginActivity.start(PickNoticeBidDetailActivity.this, EventConstant.EVENT_NOTICE_BID_DETAIL_JUMP);
                }
            }
        }, new OneKeyLoginListener() {
            @Override
            public void getOneKeyLoginStatus(int code, String result) {
                DialogHelper.dismissProgressDialog();
                if (code == 1000) {
                    OneKeyLoginEntity oneKeyLoginEntity = GsonManager.getInstance().getGson().fromJson(result, OneKeyLoginEntity.class);
                    oneKeyLoginEntity.setPlateform("Android");
                    detailModel.oneKeyLogin(oneKeyLoginEntity);
                }
            }
        });
    }
}
